package com.health.memberbackstage.web;

import com.health.memberbackstage.pojo.Ordersetting;
import com.health.memberbackstage.pojo.R.Result;
import com.health.memberbackstage.service.OrdersettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.sql.Date;

@RestController
@RequestMapping("/orderSetting")
public class OrdersettingController {

    @Autowired
    private OrdersettingService ordersettingService;

    @GetMapping("/{healthDate1}")
    private Result findNumberStatus(@PathVariable("healthDate1") Date healthDate){
        Ordersetting ordersetting = ordersettingService.findByOrderDate(healthDate);
        if (ordersetting != null){
            if (ordersetting.getNumber() > ordersetting.getReservations()) {
                return Result.success();
            }else {
                return Result.fail("当天预约数量已满，请重新选择预约时间");
            }
        }
        return Result.fail("请重新选择预约日期(没有设置当天预约量)");
    }
}
